1. Field of the Invention
The present invention relates generally to computer operating system file handling mechanisms and, more specifically, to synchronization of changed pages of data in memory to disk or other permanent storage.
2. Description of the Related Art
Synchronization is the process by which the operating system of a computer, typically a minicomputer or mainframe, from time to time writes out to disk or other non-volatile direct access storage device (DASD) pages of data in main memory that have been altered by the operation of an application program. (For convenience, the term "disk" is used herein to refer to all such DASD and other non-volatile storage devices, but the actual storage medium may be other than a disk.) Synchronization is important because it minimizes the likelihood that data will be irretrievably lost in the event of a catastrophic system crash resulting from, for example, a power outage. Minicomputers and mainframes typically do not respond to an application program altering data in main memory by immediately writing the altered pages of data to disk. Rather, they typically let the data age for some amount of time before writing the altered pages to disk because it enhances system performance. Severe I/O bottlenecks would occur in system performance if data in memory were always immediately written to disk in response to an application program altering the data.
There is a well-known tradeoff between writing changed pages immediately to disk and delaying or aging changed pages. The advantages of greater delay or aging include greater utilization of main memory, bundling multiple changes to the same page into a subsequent input/output (I/O) operation to disk and, because I/O devices usually write sequential or closely located blocks as a single I/O operation, a fundamental reduction in overall system I/O. The advantages of less delay include maximizing data recovery from system crashes and preventing main memory from becoming over-committed. Once main memory has become over-committed, caching additional data in main memory forces other data out of main memory.
A synchronization daemon is a software process or job controlled by the operating system that performs the synchronization task in the background, i.e., transparently from the perspective of a user. The daemon, in accordance with an algorithm, sweeps changed pages out to disk and updates metadata such as file allocation size and the offset of the end-of-file. A prior synchronization daemon that has been included in versions of the IBM OS/400 operating system alternated between five minute intervals of inactivity or "sleep" and intervals in which it would "wake up" and perform synchronization. The operating system maintained a synchronization list ("sync list") that listed all files that had been changed since the last synchronization. Such pending changes included both actual data and metadata. The operating system placed a file on the sync list after ten writes to that file had occurred or at the time the file was closed. A disadvantage of this approach is that when the daemon woke up after its five minute sleep interval, it caused a significant strain on available system resources. A spike of CPU and I/O activity occurred at regular five minute intervals, thus degrading the response time of applications using the system. Another prior synchronization daemon that has been included in another version of the IBM OS/400 operating system attempted to alleviate this problem by waking up every 15 seconds and then only performing synchronization of files in the sync list during a subsequent interval comprising one second of CPU time before going back to sleep. During the awake interval, it swept as many changed pages as possible to disk before returning to sleep. When it again woke up, it resumed the process of synchronizing files on the list where it had left off. If it reached the end of the list before the end of the one-second interval, it returned to the top of the list and continued synchronizing any unsynchronized files until the end of the one-second interval. Although this method reduced the size of the spike in system resources, it unnecessarily limited the time that files remained unsynchronized or "exposed" in main memory. It also made no distinction between files that had been changed very recently and files that had been changed as much as fifteen seconds earlier.
It would be desirable to provide a synchronization mechanism that does not cause a spike in system resources and that is adaptable to system conditions. These problems and deficiencies are satisfied by the present invention in the manner described below.